<?php

namespace app\admin\command;

use app\admin\model\User;
use think\console\Command;
use think\console\Input;
use think\console\Output;

class ClientCommand extends Command
{
    protected function configure()
    {
        $this->setName('handleuser')
            ->setDescription('处理七天未上传名片的用户为失效用户');
    }

    protected function execute(Input $input, Output $output)
    {
        $res = [];
        $list = User::wherenull('user_image')->where('createtime', '<', time() - 7 * 24 * 3600)->select();
        foreach ($list as $item) {
            $res[] = User::find($item['id'])->save(['status' => 'hidden']);
        }
        return '处理成功' . print_r($res, true);
    }
}